/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            systemUserInfo: {
                users: [],
                total: 0,
                records: 1,
                conditions: {
                    nameLike: '',
                    tel: '',
                    levelCd:''
                },
            }
        },
        _initMethod: function () {
                $that._listSystemUsers(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('systemUser', 'listSystemUser', function (_param) {
                $that._listSystemUsers(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on("systemUser", "systemUser", "notifyArea", function (_param) {
                $that.systemUserInfo.conditions.cityCode = _param.selectArea;
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listSystemUsers(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listSystemUsers: function (_page, _rows) {
                $that.systemUserInfo.conditions.page = _page;
                $that.systemUserInfo.conditions.row = _rows;
                var _param = {
                    params: $that.systemUserInfo.conditions
                }
                //发送get请求
                vc.http.apiGet('/user.listSystemUsers',
                    _param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.systemUserInfo.total = _json.total;
                        $that.systemUserInfo.records = _json.records;
                        $that.systemUserInfo.users = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.systemUserInfo.records,
                            dataCount: $that.systemUserInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },

            _openDeleteSystemUserModel: function (_user) {
                _user.staffId = _user.userId;
                vc.emit('deleteSystemUser','openDeleteSystemUser', _user);
            },
            _openResetSystemUserPwdModel: function (_user) {
                _user.staffId = _user.userId;
                vc.emit('resetSystemUserPwd', 'openResetSystemUserPwd', _user);
            },
            //查询
            _querySystemUserMethod: function () {
                $that._listSystemUsers(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _toUserDetailPage:function(_user){
                vc.jumpToPage('/#/pages/staff/systemUserDetail?userId='+_user.userId);
            },
            //重置
            _resetSystemUserMethod: function () {
                $that.systemUserInfo.conditions.communityId = "";
                $that.systemUserInfo.conditions.name = "";
                $that.systemUserInfo.listColumns = [];
                $that.systemUserInfo.conditions.cityCode = "";
                vc.emit('areaSelect', 'clear', {});
                $that._listSystemUsers(DEFAULT_PAGE, DEFAULT_ROWS);
            },
        }
    });
})(window.vc);